﻿<!-- 
// (c) Copyright Webber-Cross Software Ltd.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->
    
    <UserControl x:Class="WebberCross.BdcModelBuilder.TabControls.MethodDetailsTab"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    
    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="10"/>
            <RowDefinition Height="35"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <Label x:Name="lblMethods" Content="Methods:" DataContext="MDVM" />

        <DataGrid x:Name="methodGrid" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ItemsSource="{Binding Path=ModelContainer.CurrentModel.Methods.MethodDetailsList}"
                  HorizontalGridLinesBrush="Gray" VerticalGridLinesBrush="Gray" IsEnabled="{Binding Path=ModelContainer.EditMode}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False"
                  SelectedItem="{Binding Path=MDVM.SelectedDetails, Mode=OneWayToSource}" RowHeight="25">
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Edit">
                    <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                            <Button Command="{Binding Path=DataContext.MDVM.MethodDetailsCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}">
                                <Image Source="/WebberCross.BdcModelBuilder;component/Images/Edit.png" /> 
                            </Button>
                        </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTextColumn Header="Method Type" Width="100" Binding="{Binding MethodType}" IsReadOnly="True"/>
                <DataGridCheckBoxColumn Header="Include" Width="100" Binding="{Binding Include}"/>
                <DataGridTextColumn Header="Method Path" Width="200" Binding="{Binding MethodName}" IsReadOnly="True"/>
                <DataGridTextColumn Header="Return Type" Width="200" Binding="{Binding ReturnTypeName}" IsReadOnly="True"/>
            </DataGrid.Columns>
        </DataGrid>

        <Label Grid.Row="3" x:Name="lblParameters" Content="Method Parameters:" />

        <DataGrid x:Name="paramGrid" Grid.Row="4" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ItemsSource="{Binding ElementName=methodGrid, Path=SelectedItem.MethodParams.InstancePaths, Mode=TwoWay}"
                  HorizontalGridLinesBrush="DarkGray" VerticalGridLinesBrush="DarkGray" IsEnabled="{Binding Path=ModelContainer.EditMode}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False" RowHeight="25">
            <DataGrid.Columns>
                <DataGridCheckBoxColumn Header="Entity" Width="50" Binding="{Binding IsEntity}" />
                <DataGridTextColumn Header="Param" Width="50" Binding="{Binding ParamNumber}" />
                <DataGridTextColumn Header="Path" Width="300" Binding="{Binding Path}" IsReadOnly="True"/>
                <DataGridTextColumn Header="Value" Width="200" Binding="{Binding Value}"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
